#include <iostream>
#include <vector>
using namespace std;
const int N = 2e5 + 10;
vector<int> egs[N];
bool st[N];
int n, k;

int dfs(int root)
{
    st[root] = true;
    int maxdepth = 0;
    for(auto v : egs[root])
    {
        if(!st[v])
        {
            maxdepth = max(dfs(v), maxdepth);
        }
    }
    return maxdepth + 1;
}

int main()
{
    cin >> n >> k;
    for(int i = 1; i < n; i++)
    {
        int u, v; cin >> u >> v;
        egs[u].push_back(v);
        egs[v].push_back(u);
        
    }
    cout << dfs(k) << endl;
    return 0;
}